package com.yzqp.generator.util.generator.filter.column.delete;

import com.yzqp.generator.bean.TableColumnInfo;
import com.yzqp.generator.util.generator.filter.column.TableColumnFilter;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 列过滤器的 实现
 *      过滤删除 list vue 存在的属性 id createTime deleteFlag
 */
@Component
public class DeleteListVueColumnFilter implements TableColumnFilter {

    @Override
    public List<TableColumnInfo> filter(List<TableColumnInfo> tableColumnInfoList) {
        // 去除javabean生成文件不需要的列
        for (int i = 0; i < tableColumnInfoList.size(); i++) {
            TableColumnInfo column = tableColumnInfoList.get(i);
            if ("id".equals(column.getColumnName())) {
                tableColumnInfoList.remove(i);
                i--;
            } else if ("create_by".equals(column.getColumnName())) {
                tableColumnInfoList.remove(i);
                i--;
            } else if ("delete_flag".equals(column.getColumnName())) {
                tableColumnInfoList.remove(i);
                i--;
            }
        }
        return tableColumnInfoList;
    }
}
